#define DEBUG
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

typedef long long ll;
typedef long double ld;

const int maxm=18;

class Bignum {
public:
  static const int maxn=1000;
  int n, a[maxn+1];


  void readFromStr(char *s) {
    n = strlen(s);
    for (int i=1; i<=n; i++) {
      a[i] = s[n-i]-'0';
    }
  }

  void read() {
    static char s[maxn+1];
    scanf("%s", s);
    readFromStr(s);
  }

  ll get() {
    ll ret=0;
    for (int i=n; i>0; i--) {
      ret = ret*10+a[i];
    }
    return ret;
  }

  ll operator%(ll p) {
    ll rest=0;
    for (int i=n; i>0; i--) {
      rest = (rest*10%p+a[i]%p)%p;
    }
    return rest;
  }
};

int phi(int n) {
  int ret=1;
  for (int i=2; i<=sqrt(n); i++) {
    if (n%i==0) {
      ret *= i-1;
      n/=i;
      for (; n%i==0; n/=i) ret*=i;
    }
  }
  if (n>1) ret*=n-1;
  return ret;
}

ll mul(ll a, ll b, ll p) {
  return (a*b-(ll)((ld)a/p*b)*p+p)%p;
}

ll qpower(ll a, int n, ll p) {
  ll s=1;
  for (; n; n>>=1) {
    if (n&1) {
      s = mul(s, a, p);
    }
    a = mul(a, a, p);
  }
  return s;
}

void fwt(int m, ll a[], ll p) {
  if (m>0) {
    int mid=1<<(m-1);
    fwt(m-1, a, p);
    fwt(m-1, a+mid, p);
    for (int i=0; i<mid; i++) {
      ll x=a[i], y=a[mid+i];
      a[i] = (x+y)%p, a[mid+i] = (x+p-y)%p;
    }
  }
}

void ifwt(int m, ll a[], ll p) {
  if (m>0) {
    int mid=1<<(m-1);
    ifwt(m-1, a, p);
    ifwt(m-1, a+mid, p);
    for (int i=0; i<mid; i++) {
      ll x=a[i], y=a[mid+i];
      a[i] = (x+y)%p/2, a[mid+i] = (x+p-y)%p/2;
    }
  }
}

int read() {
  char c;
  int ret=0;
  for (c=getchar(); c<'0' || c>'9'; c=getchar());
  for (; c>='0' && c<='9'; c=getchar()) {
    ret = ret*10+c-'0';
  }
  return ret;
}

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static ll f[1<<maxm], b[maxm+1], c[1<<maxm];
  static int cnt[1<<maxm];
  static Bignum t;
  int m=read();
  ll p=read();
  t.read();
  for (int i=0; i<(1<<m); i++) {
    f[i]=read();
  }
  for (int i=0; i<=m; i++) {
    b[i]=read();
  }
  for (int i=0; i<(1<<m); i++) {
    cnt[i] = cnt[i>>1]+(i&1);
    c[i] = b[cnt[i]];
  }

  int x=phi(p), times;
  p *= 1<<m;
  fwt(m, c, p);
  if (t.n<=18) {
    ll temp=t.get();
    times = temp>=x ? temp%x+x : temp;
  } else {
    times = t%x+x;
  }

  for (int i=0; i<(1<<m); i++) {
    c[i] = qpower(c[i], times, p);
  }

  fwt(m, f, p);
  for (int i=0; i<(1<<m); i++) {
    f[i] = mul(c[i], f[i], p);
  }
  ifwt(m, f, p);
  p/=1<<m;

  for (int i=0; i<(1<<m); i++) {
    printf("%lld\n", f[i]%p);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
